package com.example.base.job;

import com.example.base.utils.SpringContextUtils;
import lombok.extern.slf4j.Slf4j;
import org.quartz.*;
import org.springframework.scheduling.quartz.QuartzJobBean;

/**
 * @Classname MethodJob
 * @Description TODO
 * @Date 2023/1/12 16:04
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@Slf4j
public class MethodJob extends QuartzJobBean {



    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        JobDetail jobDetail=jobExecutionContext.getJobDetail();
        JobDataMap jobDataMap=jobDetail.getJobDataMap();
        JobModel job =(JobModel) jobDataMap.get("job");
        try {
            if("1".equals(job.getType())){
                QuarztUtils quarztUtils= SpringContextUtils.getBean(QuarztUtils.class);
                quarztUtils.execute(job);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
